package com.xiu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiu.mapper.ExamGradeMapper;
import com.xiu.mapper.ExamSubjectMapper;
import com.xiu.mapper.ExamTiMapper;
import com.xiu.pojo.ExamGrade;
import com.xiu.pojo.ExamSubject;
import com.xiu.pojo.ExamTi;

@Service
public class SubjectManageService {

	@Autowired
	ExamSubjectMapper examSubjectMapper;
	
	@Autowired
	ExamGradeMapper examGradeMapper;
	
	@Autowired
	ExamTiMapper examTiMapper;
	
	//显示所有科目信息
	public List<ExamSubject> findAllSubjects(){
		return examSubjectMapper.findAllSubjects();
	}
	
	//增加科目
	public int addSubjects(ExamSubject examSubject){
		return examSubjectMapper.insert(examSubject);
	}
	
	//删除
	public int deleteSubjects(int examSubjectId){
		return examSubjectMapper.deleteByPrimaryKey(examSubjectId);
	}
	
	//通过ID查找科目信息
	public ExamSubject findSubjectById(int examSubjectId){
		return examSubjectMapper.selectByPrimaryKey(examSubjectId);
	}
	
	//修改
	public int updateSubjects(ExamSubject examSubject){
		return examSubjectMapper.updateByPrimaryKeySelective(examSubject);
	}
	
	//通过Id查找科目成绩
	public List<ExamGrade> findGradeById(int examSubjectId){
		return examGradeMapper.searchGrade(examSubjectId);
	}
	
	//通过4个条件查询
	public List<ExamGrade> searchBy(ExamGrade examGrade){
		return examGradeMapper.searchBy4(examGrade);
	}
	
	
	//查找全部成绩
	public List<ExamGrade> findAllGrade(){
		return examGradeMapper.findAllGrade();
	}
	
	//查询所有题目
	public List<ExamTi> findAllTi(){
		return examTiMapper.findAllTi();
	}
	
	//增加题目
	public int addTi(ExamTi examTi){
		return examTiMapper.insert(examTi);
	}
	
	//删除考题
	public int deleteTi(int examTiId){
		return examTiMapper.deleteByPrimaryKey(examTiId);
	}
	
	//通过Id查找考题
	public ExamTi findTiById(int examTiId){
		return examTiMapper.selectByPrimaryKey(examTiId);
	}
	
	//修改考题
	public int updateTi(ExamTi examTi){
		return examTiMapper.updateByPrimaryKeySelective(examTi);
	}
}
